package com.mysterymall.Task;

import java.util.concurrent.BlockingQueue;

//一个正式员工要要完成的任务
public class CoreJob  implements Runnable{

    //需要阻塞队列
    private final BlockingQueue<Runnable> workQueue;
    private Runnable firstCommand;

    public CoreJob(BlockingQueue<Runnable> workQueue,Runnable firstCommand){
        this.workQueue=workQueue;
        this.firstCommand =firstCommand;
    }
    @Override
    public void run() {
        //优先把刚提交的任务执行掉
        firstCommand.run();
        firstCommand =null; //设置为空的目的是为不影响firstCommand对象被GC回收


        // 暂时关闭阻塞线程的功能
//            while (true){
//                //不断的从队列中去取任务,执行
//                Runnable command =workQueue.take();
//                command.run();
//            }

    }
}
